<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="root">

    </div>
</body>
<script src="../react@17.js"></script>
<script src="../react-dom@17.js"></script>
<script src="../babel.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/prop-types/15.8.1/prop-types.js"></script>
<script type="text/babel">
    console.log(PropTypes)
    class App extends React.Component{
        state={
            msg:"好好学习,天天向上",
            num:100,
            list:[1,2,3,4,5]
        }
        render(){
            let {msg,num,list} = this.state;
            return (
                <div>
                    <Child msg={msg} num={num}  getA={()=>{

                    }}/>
                </div>
            )
        }
    }
    class Child extends React.Component{

        // 类属性 propTypes 做props校验
        // static propTypes = {
        //     msg:PropTypes.string,
        //     num:PropTypes.number,
        //     list:PropTypes.array,
        //     getA:PropTypes.func
        // }
        // static defaultProps = {
        //     list:["哈哈哈"]
        // }
        render(){
            let {msg,num,list} = this.props;
            return (
                <div>
                    <h1>我是子组件---{msg.replace("向上",'游戏')}----{num}</h1>   
                    {list}        
                 </div>
            )
        }
    }
    Child.propTypes = {
             msg:PropTypes.string,
            //  校验必填项
            num:PropTypes.number.isRequired,
            list:PropTypes.array,
            getA:PropTypes.func
    }
    //设置props默认值
    Child.defaultProps = {
          list:["张三",'李四']
    }
    ReactDOM.render(<App/>,document.getElementById("root"))
</script>
</html>